package com.mars.foodserver.controller.admin;

import com.mars.foodserver.request.FoodTypeRequest;
import com.mars.foodserver.request.SysBannerRequest;
import com.mars.foodserver.response.result.R;
import com.mars.foodserver.service.ISysBannerService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * 广告控制层
 *
 * @Author wq
 * @Date 2021-06-12
 **/
@RestController
@RequestMapping("admin/sysBanner")
@AllArgsConstructor
public class AdminBannerController {

    private final ISysBannerService sysBannerService;


    /**
     * 添加
     *
     * @param request 请求参数
     * @return R
     */
    @PostMapping("/add")
    public R add(@RequestBody SysBannerRequest request) {
        sysBannerService.add(request);
        return R.success();
    }

    /**
     * 更新
     *
     * @param request 请求参数
     * @return R
     */
    @PostMapping("/update")
    public R update(@RequestBody SysBannerRequest request) {
        sysBannerService.update(request);
        return R.success();
    }

    /**
     * 删除
     *
     * @param id ID
     * @return R
     */
    @GetMapping("/delete")
    public R delete(Integer id) {
        sysBannerService.delete(id);
        return R.success();
    }

    /**
     * 详情
     *
     * @param id ID
     * @return R
     */
    @GetMapping("/detail")
    private R detail(Integer id) {
        return R.success(sysBannerService.detail(id));
    }


    /**
     * 分页
     *
     * @param request 请求参数
     * @return R
     */
    @PostMapping("/page")
    private R page(@RequestBody SysBannerRequest request) {
        return R.success(sysBannerService.page(request));
    }

}